function xOut=mtimes2(x1,x2)

nx1 = size(x1);
nx2 = size(x2);

nr = nx1(1);
nc = nx2(2);

nd = size(x1.d,3);

xOut = deriv1f(zeros(nr,nc),0,nd);
x1v = getval(x1);
x2v = getval(x2);
xOut.v = x1v*x2v;

for i=1:nd
  xOut.d(:,:,i) = reshape(x1.d(:,:,i),nx1) * x2v...
      + x1v * reshape(x2.d(:,:,i),nx2);
end

